<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: yangweijie <yangweijiester@gmail.com> <code-tech.diandian.com>
// +----------------------------------------------------------------------

namespace Admin\Model;
use Think\Model;

/**
 * 插件模型
 * @author yangweijie <yangweijiester@gmail.com>
 * @date    2013-08-14 11:31:21
 */

class PlinkModel extends Model {

    /**
     * 查找后置操作
     */
    public function update($data = null){
        //create整理有效字段
//        dump($data);
        $data = $this->create($data);
        if(empty($data)){
            return false;
        }

        if(empty($data['id'])){
//            $data['ctime']=time();
            $id = $this->add();
            if(!$id){
                $this->error = "新增轮播图出错";
                return false;
            }
        }else{
//            $data['utime']=time();
            $status = $this->save();
            if(false === $status){
                $this->error = "更新轮播图出错";
                return false;
            }
        }
        return $data;
    }

}
